/***
### Step 6: Create Quarterly Supply Chain Network
**File:** `1_1_SC_Network_Qtr.do`  
**Language:** Stata  
**Description:** Creates a quarterly version of the supply chain network by replicating annual data across quarters.
- **Inputs:**
  - SCnetwork2.dta 
  - SCnetwork2_saveold.dta
- **Outputs:**
  - SCnetwork2_Q.dta
  - SCnetwork2_Q.csv
***/

global dir "your_path"

use "&dir.\SCnetwork2.dta", clear 

append using "&dir.\SCnetwork2.dta"
append using "&dir.\SCnetwork2.dta"
append using "&dir.\SCnetwork2.dta"
sort gvkey1 fyear gvkey2 

by pairid fyear, sort: gen quarter=_n

sort gvkey1 fyear gvkey2 quarter

gen yearq=yq(fyear, quarter)
format yearq %tq

egen time_id=group(yearq)

sort time_id

save "&dir.\SCnetwork2_Q.dta", replace

export delimited using "&dir.\SCnetwork2_Q.csv", replace 


*** ------------------------------------- ***
*** ------ Same thing for the VTNIC: ---- ***
*** ------------------------------------- ***


use "&dir.\VTNIC_20.dta", clear 

append using "&dir.\VTNIC_20.dta"
append using "&dir.\VTNIC_20.dta"
append using "&dir.\VTNIC_20.dta"
sort gvkey1 fyear gvkey2 

egen pairid=group(gvkey1 gvkey2)

by pairid fyear, sort: gen quarter=_n

sort gvkey1 fyear gvkey2 quarter

gen yearq=yq(fyear, quarter)
format yearq %tq

egen time_id=group(yearq)

sort time_id

save "&dir.\VTNIC_20_Q.dta", replace

export delimited using "&dir.\VTNIC_20_Q.csv", replace 
